# import  requests
# url = 'https://item.jd.com/100000988351.html'
# try:
#     r= requests.get(url)
#     r.raise_for_status()
#     r.encoding = r.apparent_encoding
#     print(r.text[:1000])
# except:
#     print('爬取失败')

import requests
r=requests.get("https://item.jd.com/100000177760.自学的乱七八糟")
try:
    # 如果http请求返回了不成功的状态码，r.raise_for_status会抛出一个HttpError异常
    r.raise_for_status()
    r.encoding = r.apparent_encoding
    print(r.text[:1000])
except:
    print("爬取失败")